/**
 * Created by 14229 on 2020/2/19.
 */
public class Test12 {
    public static void main(String[] args) {

        int[][] A = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                     {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
                     {0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0},
                     {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                     {0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0},
                     {0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0},
                     {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                     {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                     {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                     {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                     {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
        };
        int count = 0;
        for (int i = 0; i < A.length; i++) {
            for (int j = 0; j < A[i].length; j++) {
                if (A[i][j]!=0){
                    count++;
                }
            }
        }
        int[][] B = new int[count+1][3];
        B[0][0] = A.length; // 11行
        B[0][1] = A[0].length; // 11列
        B[0][2] = count; // 非0个数
        int a = 1;
        for (int i = 0; i <A.length ; i++) {
            for (int j = 0; j <A[i].length ; j++) {
                if (A[i][j]!=0){
                    B[a][0]=A[i][j];
                    B[a][1]=i;
                    B[a][2]=j;
                    a++;
                }
            }
        }

        for (int i = 0; i <B.length ; i++) {
            for (int j = 0; j <B[i].length ; j++) {
                System.out.print(B[i][j]+" |");
            }
            System.out.println();
        }
        test01(B);
    }

    public static void test01(int[][] arr){
        int[][] A = new int[arr[0][0]][arr[0][1]];

        for (int i = 1; i <arr.length ; i++) {
            A[arr[i][1]][arr[i][2]] = arr[i][0];
        }
        for (int i = 0; i <A.length ; i++) {
            for (int j = 0; j <A[i].length ; j++) {
                System.out.print(A[i][j]+" |");
            }
            System.out.println();
        }
    }
}
